package com.stylefeng.guns.modular.vpn_business_info.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.VpnBusinessDataInfo;
import com.stylefeng.guns.modular.vpn_business_info.service.IVpnBusinessDataInfoService;

import javax.servlet.http.HttpServletResponse;

/**
 * 业务数据控制器
 *
 * @author fengshuonan
 * @Date 2020-03-09 19:23:55
 */
@Controller
@RequestMapping("/vpnBusinessDataInfo")
public class VpnBusinessDataInfoController extends BaseController {

    private String PREFIX = "/vpn_business_info/vpnBusinessDataInfo/";

    @Autowired
    private IVpnBusinessDataInfoService vpnBusinessDataInfoService;

    /**
     * 跳转到业务数据首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "vpnBusinessDataInfo.html";
    }

    /**
     * 获取业务数据列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return vpnBusinessDataInfoService.selectList(null);
    }

    /**
     * 拉新用户数据
     * @return
     */
    @RequestMapping(value = "/newUserInfo")
    @ResponseBody
    public Object getNewUserInfo(@RequestParam(name = "beginTime",required = false) String beginTime,
                                 @RequestParam(value = "endTime",required = false) String endTime) {
        return vpnBusinessDataInfoService.findNewUserList(beginTime,endTime);
    }

    /**
     * 活跃用户数据
     * @return
     */
    @RequestMapping(value = "/retentionUserInfo")
    @ResponseBody
    public Object getRetentionUserInfo(@RequestParam(name = "beginTime",required = false) String beginTime,
                                       @RequestParam(value = "endTime",required = false) String endTime) {
        return vpnBusinessDataInfoService.findRetentionUserList(beginTime,endTime);
    }

    /**
     * 财务数据
     * @param beginTime
     * @param endTime
     * @return
     */
    @RequestMapping(value = "/financialInfo")
    @ResponseBody
    public Object getFinancialInfo(@RequestParam(name = "beginTime",required = false) String beginTime,
                                   @RequestParam(value = "endTime",required = false) String endTime) {
        return vpnBusinessDataInfoService.findFinancialInfo(beginTime,endTime);
    }

    /**
     * 导出数据表格
     * @param type
     * @param beginTime 开始日期
     * @param endTime 结束日期
     * @param response
     */
    @RequestMapping("/download/excel")
    @ResponseBody
    public void downloadOrderInfo(@RequestParam(value = "type",required = false) String type,
                                  @RequestParam(value = "beginTime",required = false) String beginTime,
                                  @RequestParam(value = "endTime",required = false) String endTime,
                                  HttpServletResponse response){
        vpnBusinessDataInfoService.exportExcel(type,beginTime,endTime,response);
    }
}
